<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>员工列表</title>
    <script src="/js/vue.js"></script>
    <script src="/js/jquery.js"></script>
    <script src="/js/axios.min.js"></script>
    <script src="../js/lib-master/index.js"></script>
  
    <link rel="stylesheet" href="../js/lib-master/theme-chalk/index.css">

</head>
<body>
    <div id="app">
        输入搜索：
        <el-input placeholder="账户/姓名" prefix-icon="el-icon-search" v-model="empNameSelect" style="width: 300px;"></el-input>
        <el-button type="primary" icon="el-icon-search" @click="getAllEmpName()" >搜索</el-button>
        <el-table :data="employeeData" :cell-style="rowStyle">
          <el-table-column prop="employeeID" label="员工编号"></el-table-column>
          <el-table-column prop="employeePicture" label="头像">
            <template slot-scope="scope">
              <img :src="scope.row.employeePicture" min-width="70px" height="70px">
            </template>
          </el-table-column>
          <el-table-column prop="employeeAccount" label="账号"></el-table-column>
          <el-table-column prop="employeeName" label="姓名"></el-table-column>
          <el-table-column prop="employeePosition" label="职位"></el-table-column>
          <el-table-column prop="employeePhone" label="手机号"></el-table-column>
          <el-table-column prop="employeeDate" label="注册时间"></el-table-column>
        </el-table>
    </div>
    <script src="/js/backcommon.js"></script>
    <script>
    
        let vm = new Vue({
          el: "#app",
          data: {
            empNameSelect:'',
            employeeData: [],
            
            
          },
          created: function () {
            this.getEmployeeList()
          },
          methods: {
            rowStyle() {
              return "text-align:center";
            },
            //员工操作
            getEmployeeList: function () {
              axios.get("/employee/getAll").then(function (resp) {
                vm.employeeData = resp.data.data
              })
            },
            //员工查询名字或账号
            getAllEmpName: function () {
              axios.get("/employee/getAllAccount", { params: { empAccount: vm.empNameSelect } })
                .then(function (resp) {
                  if (200 == resp.data.code) {
                    if(resp.data.data==0){
                      alert('没有此员工信息')
                    }else{
                      vm.employeeData=resp.data.data
                    }
                  }
                })
            },
            //重置
            empReset: function () {
              vm.getEmployeeList()
            }
          }
        })
      </script>
</body>
</html>